home *** CD-ROM | disk | FTP | other *** search
-
- I wrote the MDATES Class because I couldn't find a good set of Date functions
- anywhere!! Not that this one is the best in the world, but it gets the job
- done pretty well for me! I hope it's useful to you, and if not... Hey, it's
- free isn't it!
-
- Below is an outline of the avail. functions and a breif description....
-
- Matthew Rhoades........................................................
-
-
-
-
- //***************************************************************************
- void SystemDate(char *date); // returns CCYYMMDD Format
-
- Function to return the system date in char * CCYYMMDD Format
- Ex: MDates date;
- date.SystemDate(Buffer);
- Buffer = 19940308 <today for me>
-
-
-
- //***************************************************************************
- void PrintDate(char *date); // returns MMM DD, YYYY
-
- Function to return the system date in a "Pretty" Format for output.
- Ex: MDates date;
- date.PrintDate(Buffer);
- Buffer = Mar 08, 1994 <today for me>
-
-
-
- //***************************************************************************
- long SubMonths(long date, int x); // returns CCYYMMDD Long
-
- Function to subtract x number of months from a date.
- Ex: long result;
- MDates date;
- result = date.SubMonths(19940308, 4);
- result = 19941108
-
-
-
- //***************************************************************************
- long SubDays(long date, int x); // returns CCYYMMDD Long
-
- Function to subtract x number of days from a date.
- Ex: long result;
- MDates date;
- result = date.SubDays(19940308, 4);
- result = 19940304
-
-
-
- //***************************************************************************
- long Date2Long(char *date); // CCYYMMDD Format
-
- Function to Convert a char *date into a long
- Ex: long result;
- MDates date;
- result = date.Date2Long("19940308");
- result = 19940308L
-
-
-
- //***************************************************************************
- int Date2String(long date, char *newdate); // pass CCYYMMDD Format
-
- Function to Convert a char *date into a long
- Ex: int result;
- char Date[9];
- MDates date;
- result = date.Date2String(19940308, Date);
- result = 1 // 1 for OK and -1 for Invalid Date
- Date = "19940308"
-
-
-
- //***************************************************************************
- int DaysBetween(char *dateone, char *datetwo); // CCYYMMDD Format
-
- Function to Compute days between two dates
- Ex: int result;
- MDates date;
- result = date.DaysBetween("19940308", "19940304");
- result = 4
-
-
-
-
- //***************************************************************************
- void DateFormat(char *dt, char *result, int format);
-
- Function to Format a given date to the specified format
- Support formats are:
- STANDARD : MM/DD/YY
- MMDDYY : same
- YYMMDD : same
-
- Ex: MDates date;
- date.DateFormat( "19940308", result, STANDARD);
- result = 03/08/94
-
-
-
-
- //***************************************************************************
- void InitDate(char *dt, char *result, int format);
-
- Function to Init a given date from the specified format
- (Opposite of DateFormat)
- Support formats are:
- STANDARD : MM/DD/YY
- MMDDYY : same
- YYMMDD : same
-
- Ex: MDates date;
- date.DateFormat( "03/08/94", result, STANDARD);
- result = "19940308"
-
-
-
-
- //***************************************************************************
- int IsValidDate( char *s ); // pass CCYYMMDD Format
-
- Function to test for date validity including leap years
- Ex: int result;
- MDates date;
- result = date.IsValidDate( "19940308");
- result = 1 for OK, -1 for Invalid Date
-
-
-
-
- //***************************************************************************
- long Date2Julian(char *date); // CCYYMMDD Format
-
- Function to Convert a char *date into long Julian Format
- Ex: long result;
- MDates date;
- result = date.Date2Julian( "19940308");
- result = 1755457L
-
-
-
- //***************************************************************************
- long Julian2Long(long Julian); // CCYYMMDD Format returned
-
- Function to Convert a long Julian into long Date Format
- Ex: long result;
- MDates date;
- result = date.Julian2Long(1755457);
- result = 19940308L
-
-
-
-
- //***************************************************************************
- void Julian2String(long Julian, char *string); // returns CCYYMMDD Format
-
- Function to Convert a long Julian into char *Date Format
- Ex: char result[9];
- MDates date;
- date.Julian2Long(1755457, result);
- result = "19940308"
-
-
-
- //***************************************************************************
- long DMYtoJulian(int Day, int Month, int Year); // Low Level Julian Converter
-
- Low Level Date to Julian Convertion Function...
- Ex: long result;
- MDates date;
- result = date.DMYtoJulian(8, 3, 94);
- result = 1755457L
-
-
-
- //***************************************************************************
- int Valid_Date( char *s ); // MMDDYY Format (Low Level)
-
- Low Level Date Validation Function
- Ex: int result;
- MDates date;
- result = date.Valid_Date("030894");
- result = 1 for OK, -1 for Invalid Date
-
-
-
-